package com.smarthome.domain.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dhc
 * @date 2015年10月16日 下午3:31:40
 * @title
 */
public enum SmsTypeEnum {
	COMMON(1l,"通用短信类型"),
	COMMON_CAPTCHA(10L,"通用验证码",4),	
	/**用户注册*/
	REGIST_VALIDATE_CODE(11L,"用户注册验证码",4,60 * 2L),
	/**找回密码*/
	FIND_PASSWORD(12L,"找回密码验证码",4,60 * 30L),
	/**添加房屋门牌验证码,业主审核*/
	ADD_DOOR_CODE(13l,"添加房屋门牌验证码"),
	/**通知取快递*/
	RECEIVE_KD(14l,"通知取快递"),
	/**洗衣取件短信提醒**/
	GET_WASH_CODE(15l,"通知取衣服"),	
	PRIPERTY_SERVICE(16l,"物业缴费服务");
	
	private Long code;
	private String name;
	/**模板参数*/
	private Map<String,String> paramMap;
	
	/**验证码长度*/
	private Integer captchaLenght;
	/**超时时间 秒为单位  当为空或者-数时不超时*/
	private Long overTime;
	
	private static Map<Long,SmsTypeEnum>map = new HashMap<Long, SmsTypeEnum>();
	
	
	private SmsTypeEnum(Long code, String name) {
		this.code = code;
		this.name = name;
	}
	
	private SmsTypeEnum(Long code, String name,Integer captchaLenght) {
		this.code = code;
		this.name = name;
		this.captchaLenght = captchaLenght;
	}
	private SmsTypeEnum(Long code, String name,Long overTime) {
		this.code = code;
		this.name = name;
		this.overTime = overTime;
	}
	private SmsTypeEnum(Long code, String name,Integer captchaLenght,Long overTime) {
		this.code = code;
		this.name = name;
		this.captchaLenght = captchaLenght;
		this.overTime = overTime;
	}
	
	static{
		for(SmsTypeEnum e : SmsTypeEnum.values()){
			map.put(e.getCode(), e);
		}
	}
	
	public Long getCode() {
		return code;
	}

	public String getName() {
		return name;
	}
	
	public Map<String, String> getParamMap() {
		return paramMap;
	}
	public Long getOverTime() {
		return overTime;
	}
	
	public Integer getCaptchaLenght() {
		if(null == captchaLenght) this.captchaLenght = 6;
		return captchaLenght;
	}
	
	public static SmsTypeEnum getSmsTypeEnumByCode(Long code){
		
		return map.get(code);
	}
}
